package cn.tedu.egmvc1.controller;

import cn.tedu.egmvc1.mapper.EmpMapper;
import cn.tedu.egmvc1.pojo.entity.Emp;
import cn.tedu.egmvc1.pojo.vo.EmpVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/emp/")
public class EmpController {
    @Autowired(required = false)
    private EmpMapper empMapper;

    @RequestMapping("insert")
    public String insert(Emp emp){
        /*
            1.直接调用接口方法
         */
        empMapper.insert(emp);

        return "添加成功";
    }

    @RequestMapping("select")
    public List<EmpVO> select(){
        /*
            1.查询所有用户的 姓名和岗位
         */
        return empMapper.select();
    }

    @RequestMapping("update")
    public String update(Emp emp){
        empMapper.update(emp);
        return "修改成功";
    }

    @RequestMapping("delete")
    public String delete(int id){
        empMapper.delete(id);

        return "删除成功";
    }
}







